package br.com.mumakgnod.teste;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JButton;
import javax.swing.JFrame;

import br.com.mumakgnod.engine.GameGridJPanel;
import br.com.mumakgnod.engine.SpriteJFrame;
import br.com.mumakgnod.engine.SpriteJFrame.HEADING;
import br.com.mumakgnod.engine.Strings;

public class GameMain {
	private JFrame frame;
	private GameGridJPanel gameGrid;
	private Character character;
	
	private SpriteJFrame.HEADING heading;
	
	public GameMain() {
		frame = new JFrame(Strings.getString("GameMain.WINDOW_NAME")); //$NON-NLS-1$
		gameGrid = new GameGridJPanel();
		character = new Character();
		
		gameGrid.setSize(300, 300);
		gameGrid.addSprite(character);
		
		JButton button1 = new JButton("Teste1");
		button1.setSize(100, 20);
		button1.addActionListener(new ActionListener() {
			
			@Override
			public void actionPerformed(ActionEvent arg0) {
				changeHeading();
			}
		});
		frame.add(button1);
		
		initFrame();
	}
	
	private void initFrame() {
		frame.add(gameGrid);
		frame.setSize(300, 300);
		frame.setVisible(true);
		frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
	}
	
	private void changeHeading() {
		switch (character.getHeading()) {
		case N:
			character.setHeading(HEADING.E);
			break;
		case E:
			character.setHeading(HEADING.S);
			break;
		case S:
			character.setHeading(HEADING.O);
			break;
		case O:
			character.setHeading(HEADING.N);
			break;
		default:
			break;
		}
		
		frame.repaint();
	}

	public static void main(String[] args) {
		GameMain gm = new GameMain();
	}

}
